﻿using DevExpress.Data;
using DevExpress.Utils;
using DevExpress.XtraEditors.Repository;

namespace EyFramework.Library
{
    public class GridColumnInfo
    {
        ///  <summary>
        ///  列字段代码
        ///  </summary>
        private string col_cde;

        public string COL_CDE
        {
            get { return col_cde; }
            set { col_cde = value; }
        }

        ///  <summary>
        ///  列名
        ///  </summary>
        private string col_nm;

        public string COL_NM
        {
            get { return col_nm; }
            set { col_nm = value; }
        }

        ///  <summary>
        ///  列宽
        ///  </summary>
        private int col_width;

        public int COL_WIDTH
        {
            get { return col_width; }
            set { col_width = value; }
        }

        ///  <summary>
        ///  是否只读列
        ///  </summary>
        private bool col_readonly;

        public bool COL_READONLY
        {
            get { return col_readonly; }
            set { col_readonly = value; }
        }

        private string formatstring;

        ///  <summary>
        ///  格式化字符串
        ///  </summary>
        public string Formatstring
        {
            get { return formatstring; }
            set { formatstring = value; }
        }

        private FormatType formattype;

        ///  <summary>
        ///  格式化类型
        ///  </summary>
        public FormatType Formattype
        {
            get { return formattype; }
            set { formattype = value; }
        }

        private string sumdisplayformat;

        public string Sumdisplayformat
        {
            get { return sumdisplayformat; }
            set { sumdisplayformat = value; }
        }

        private SummaryItemType summaryitemtype;

        public SummaryItemType Summaryitemtype
        {
            get { return summaryitemtype; }
            set { summaryitemtype = value; }
        }

        private RepositoryItem _columnedit;

        public RepositoryItem Columnedit
        {
            get { return _columnedit; }
            set { _columnedit = value; }
        }

        public GridColumnInfo()
        {
            InitDeflt();
        }

        ///  <summary>
        ///  设置当前对象的默认值
        ///  </summary>
        private void InitDeflt()
        {
            this.col_cde = string.Empty;
            this.col_nm = string.Empty;
            this.col_width = -1;
            this.col_readonly = true;
            this.formattype = FormatType.None;
            this.formatstring = string.Empty;
            this.sumdisplayformat = string.Empty;
            this.summaryitemtype = SummaryItemType.None;
        }

        public GridColumnInfo(string pCol_cde, string pCol_nm)
            : this()
        {
            this.col_cde = pCol_cde;
            this.col_nm = pCol_nm;
        }

        public GridColumnInfo(string pCol_cde, string pCol_nm, int pCol_Width)
            : this(pCol_cde, pCol_nm)
        {
            this.col_width = pCol_Width;
        }

        public GridColumnInfo(string pCol_cde, string pCol_nm, bool pCol_ReadOnly)
            : this(pCol_cde, pCol_nm)
        {
            this.col_readonly = pCol_ReadOnly;
        }

        public GridColumnInfo(string pCol_cde, string pCol_nm, int pCol_Width, bool pCol_ReadOnly) :
            this(pCol_cde, pCol_nm, pCol_ReadOnly)
        {
            this.col_width = pCol_Width;
        }

        public GridColumnInfo(string pCol_cde, string pCol_nm, int pCol_Width, bool pCol_ReadOnly, FormatType pFormattype, string pFormatstring)
            : this(pCol_cde, pCol_nm, pCol_Width, pCol_ReadOnly)
        {
            this.formattype = pFormattype;
            this.formatstring = pFormatstring;
        }

        public GridColumnInfo(string pCol_cde, string pCol_nm, int pCol_Width, bool pCol_ReadOnly, FormatType pFormattype, string pFormatstring, SummaryItemType pSummaryitemtype, string pSumdisplayformat)
            : this(pCol_cde, pCol_nm, pCol_Width, pCol_ReadOnly, pFormattype, pFormatstring)
        {
            this.sumdisplayformat = pSumdisplayformat;
            this.summaryitemtype = pSummaryitemtype;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }
            return this.COL_CDE == (obj as GridColumnInfo).COL_CDE;
        }
    }
}